import request from "@/netword/request";


const fun = {};


// 分页查询所有信息
fun.getList = async (product) => {
    const res = await request({
        url: "/a/content/product/list",
        method: "post",
        params: {
            productName: product.productName,
            pageNo: product.pageNo,
            pageSize: product.pageSize,
        }
    })
    return res.data;
}



//保存数据
fun.saveProduct = async (product) => {
    const res = await request({
        url: "/a/content/product/save",
        method: "put",
        params: {
            productImage: product.productImage,
            productName:product.productName,
            productContent: product.productContent,
            productTypeId:product.productTypeId,
            sort: product.sort,
            remarks: product.remarks,
        }
    })
    return res.data;
}



//更新数据
fun.updateProduct = async (product) => {
    const res = await request({
        url: "/a/content/product/update",
        method: "post",
        params: {
            id: product.id,
            productImage: product.productImage,
            productName:product.productName,
            productContent: product.productContent,
            productTypeId:product.productTypeId,
            sort: product.sort,
            remarks: product.remarks,
        }
    })
    return res.data;
}



//修改数据状态（正常，停用，删除）
fun.saveStatus = async (id,status) => {
    const res = await request({
        url: "/a/content/product/updateStatus",
        method: "post",
        params: {
            id: id,
            status:status
        }
    })
    return res.data;
}


//查询单条数据
fun.getProduct = async (id) => {
    const res = await request({
        url: "/a/content/product/get",
        method: "get",
        params: {
            id: id
        }
    })
    return res.data;
}


export default fun;